package com.lhb;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.SmartInstantiationAwareBeanPostProcessor;

/**
 * @Program: spring
 * @Description:
 * @Author: LHB
 * @Version: v0.0.1
 * @Time: 2021-08-05 12:59
 **/
public class JdkProxyBeanPostProcessor implements SmartInstantiationAwareBeanPostProcessor {
	public Object getEarlyBeanReference(Object bean, String beanName) throws BeansException {

		// 假设:A 被切点命中 需要创建代理  @PointCut("execution(* *..InstanceA.*(..))")
		if(bean instanceof InstanceA) {
			JdkDynimcProxy jdkDynimcProxy = new JdkDynimcProxy(bean);
			return  jdkDynimcProxy.getProxy();
		}
		return bean;
	}
}
